#include "sg.h"
#include "../board.h"
#include "../soundManager.h"

// checks to see if there is something of interest in
// the line of sight
void SG::look() {
	Board &board = *getCurrentBoard();

	int lookX = x;
	int lookY = y;

	int dx;
	int dy;
	getDxAndDy(o, dx, dy);

	// advance off of the the self-same tile
	lookX += dx;
	lookY += dy;

	while (board.inBounds(lookX, lookY)) {
		// can't look past wall
		if (board.getTile(lookX, lookY) == WALL) {
			break;
		}

		// get the object we're currently looking at
		Actor *obj;
		ObjectType objType = board.getObject(lookX, lookY, obj);

		if (objType == OB_ILL && board.getIll().isKillable())
		{
			playSfx(SFX_GUARD_DISCOVERS_PLAYER);
			obj->kill();
			board.setLose();
			return;
		}
		else if (objType == OB_GUARD)
		{
			// can't see past enemy
			return;
		}
		else if (objType == OB_DOG)
		{
			// can't see past enemy
			return;
		}
		// if target is a super guard and not self
		else if (objType == OB_SG && !(this->isAt(lookX, lookY)))
		{
			// can't see past enemy
			return;
		}
		else if (objType == OB_FOOD)
		{
			// no effect on super guard
		}
		else if (objType == OB_DEADBODY)
		{
			// no effect on super guard
		}

		lookX += dx;
		lookY += dy;
	}
}

// end of sg.cpp
